home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / PowerPC / Dev / PPCRelease / Examples / IPC / Msg3PPC.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-06  |  1.9 KB  |  92 lines

  1. /* Msg3 and Msg3PPC.elf
  2.  *
  3.  * This test program sends 1000 messages to the PPC and
  4.  * shows how long this takes.
  5.  * The Messages are send synchron and every msg must
  6.  * be replied after another.
  7.  *  Each Message has the Body "Text sent by M68k processor\n"
  8.  */
  9.  
  10. #include <exec/types.h>
  11. #include <exec/nodes.h>
  12. #include <exec/lists.h>
  13. #include <exec/memory.h>
  14. #include <utility/tagitem.h>
  15. #include <powerup/ppclib/interface.h>
  16. #include <powerup/ppclib/message.h>
  17. #include <powerup/ppclib/tasks.h>
  18. #include <powerup/gcclib/powerup_protos.h>
  19.  
  20. #define    DEBUG    0
  21.  
  22. #if DEBUG
  23. #define    D(x)    x;
  24. #else
  25. #define    D(x)    ;
  26. #endif
  27.  
  28. #define text    "Text sent by PPC processor\n"
  29.  
  30. struct StartupData
  31. {
  32.     ULONG    MsgCount;
  33. };
  34.  
  35. BPTR    MyFile;
  36.  
  37. int    main(void)
  38. {
  39. struct TagItem        MyTags[10];
  40. struct StartupData    *StartupData;
  41. void            *PPCPort;
  42. void            *ReplyPort;
  43. void            *M68kMsg;
  44. void            *Body;
  45. ULONG            result;
  46. ULONG            MsgCount;
  47. ULONG            i;
  48.  
  49.   StartupData    =(struct StartupData *) PPCGetTaskAttr(PPCTASKTAG_STARTUP_MSGDATA);
  50.  
  51.   MsgCount    =    StartupData->MsgCount;
  52.  
  53. #if DEBUG
  54.   if (MyFile = PPCOpen("con:0/0/640/200/MessageDemo - PPC output/CLOSE", MODE_NEWFILE))
  55.   {
  56. #endif
  57.  
  58.     if (PPCPort=(void*) PPCGetTaskAttr(PPCTASKTAG_MSGPORT))
  59.     {
  60.       D(PPCfprintf(MyFile,"Waiting for M68k message\n"));
  61.  
  62.       for (i=0;i<MsgCount;i++)
  63.       {
  64.         PPCWaitPort(PPCPort);
  65.  
  66.         D(PPCfprintf(MyFile,"Getting message\n"));
  67.  
  68.         if (M68kMsg = PPCGetMessage(PPCPort))
  69.         {
  70.           D(PPCfprintf(MyFile,"Message: %s\n",
  71.                               PPCGetMessageAttr(M68kMsg, PPCMSGTAG_DATA)));
  72.           PPCReplyMessage(M68kMsg);
  73.         }
  74.         else
  75.         {
  76.           D(PPCfprintf(MyFile,"Did not get m68k msg\n"));
  77.         }
  78.       }
  79.     }
  80.     else
  81.     {
  82.       D(PPCfprintf(MyFile,"Could not find PPC Task`s msgport\n"));
  83.     }
  84.  
  85.     D(PPCfprintf(MyFile,"Closing output\n"));
  86. #if DEBUG
  87.     PPCClose(MyFile);
  88.   }
  89. #endif
  90. }
  91.  
  92.